package cn.stylefeng.guns.modular.rest;


import cn.stylefeng.guns.sys.modular.system.model.UserDto;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.reqres.response.SuccessResponseData;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * 绑定控制器
 *
 * @author
 * @Date 2019-11-18 13:24:11
 */
@RestController
@RequestMapping("/gunsApi/user")
public class ApiNeedTokenUserController extends BaseController {
    private final UserService userService;

    public ApiNeedTokenUserController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 绑定
     */
    @RequestMapping(value = "change/pwd")
    public Object changePwd(String account, String oldPassword, String newPassword) {

        Map map = new HashMap();
        SuccessResponseData SUCCESS_TIP = new SuccessResponseData();
        userService.changePwdForApi(account, oldPassword, newPassword);
        SUCCESS_TIP.setData(map);
        return SUCCESS_TIP;
    }

    @PostMapping("/add")
    public ResponseData addUser(UserDto user) {
        this.userService.addUser(user);
        return SUCCESS_TIP;
    }
}


